package com.hugh.edu.controller;

import com.hugh.edu.util.MapCacheUtil;
import com.hugh.edu.service.SecurityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/security")
public class SecurityController {

    /**
     * Spring容器和SpringMVC容器是有层次的（父子容器）
     * Spring容器：service对象+dao对象
     * SpringMVC容器：controller对象，，，，可以引用到Spring容器中的对象
     */
    @Autowired
    private SecurityService securityService;

    @Autowired
    private MapCacheUtil mapCacheUtil;

    @GetMapping("/login")
    public String login() throws Exception {
        return "index";
    }

    @GetMapping("/login/submit")
    public String submit(String username, String password) throws Exception {

        mapCacheUtil.add(username, password, 5*60*1000);
        Object o = mapCacheUtil.get(username);
        System.out.println("username:"+ o);
        return "redirect:/resume/queryResumeList?username=" + username;
    }

}
